import { createRouter, createWebHistory } from 'vue-router'
import Layout from '@/views/layout/index.vue'
import Find from '@/views/layout/components/Find.vue'
import Recommend from '@/views/layout/components/Recommend.vue'
import Publish from '@/views/publish/index.vue'
import PublishSubmit from '@/views/publish/components/PublishSubmit.vue'
import CreatorHome from '@/views/publish/components/CreatorHome.vue'
import SubmitUpload from '@/views/publish/components/SubmitUpload.vue'
import NoteManager from '@/views/publish/components/NoteManager.vue'
import User from '@/views/layout/components/User.vue'
import Notice from '@/views/layout/components/Notice.vue'
import SubmitUploadPT from '@/views/publish/components/SubmitUploadPT.vue'
import pTPublishVue from '@/views/publish/components/pTPublish.vue'
import AllNotes from '@/views/publish/components/NoteManager/AllNotes.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'layout',
      component: Layout,
      children: [
        // {
        //   path: '', // 将根路径的 path 设置为空
        //   redirect: { name: 'find' } // 重定向到 'find' 路由
        // },
        {
          path: '',
          name: 'find',
          component: Find,
          children: [
            {
              path: '',
              name: 'recommend',
              component: Recommend
            }
          ]
        },
        {
          path: 'user',
          name: 'User',
          component: User
        },
        {
          path: 'notice',
          name: 'Notice',
          component: Notice
        }
      ]
    },
    {
      path: '/creator',
      name: 'creator',
      component: Publish,
      children: [
        {
          path: '',
          name: 'submit',
          redirect: '/creator/upMT',
          component: PublishSubmit,
          children: [
            {
              path: 'upMT',
              name: 'upload',
              component: SubmitUpload
            },
            {
              path: 'upPT',
              name: 'upPT',
              component: SubmitUploadPT
            }
          ]
        },
        {
          path: 'pTPublish',
          name: 'pTPublish',
          component: pTPublishVue,
          props: true
        },
        {
          path: 'home',
          name: 'home',
          component: CreatorHome
        },
        {
          path: 'notemanager',
          name: 'noteManager',
          component: NoteManager,
          children: [
            {
              path: 'allnotes',
              name: 'allnotes',
              component: AllNotes
            }
          ]
        }
      ]
    }
  ]
})

export default router
